/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.Frame;
import javax.swing.JOptionPane;

/**
 *
 * @author Dell
 */
public class frameHOMEPAGE extends javax.swing.JFrame {

    /**
     * Creates new form frameHOMEPAGE
     */
    public frameHOMEPAGE() {
        initComponents();
       
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDesktopPane1 = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        radioDOKTER = new javax.swing.JRadioButton();
        radioADMIN = new javax.swing.JRadioButton();
        buttonMasukHOME = new javax.swing.JButton();
        buttonKeluar = new javax.swing.JButton();
        frameLOGIN = new javax.swing.JInternalFrame();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        username1 = new javax.swing.JTextField();
        butonLogin = new javax.swing.JButton();
        butonKembaliLogin = new javax.swing.JButton();
        password1 = new javax.swing.JPasswordField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Times New Roman", 0, 24));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Sistem Pencarian Obat Berdasarkan Kategori Penyakit");

        radioDOKTER.setText("DOKTER");
        radioDOKTER.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        radioDOKTER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioDOKTERActionPerformed(evt);
            }
        });

        radioADMIN.setText("ADMINISTRATOR");
        radioADMIN.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        radioADMIN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioADMINActionPerformed(evt);
            }
        });

        buttonMasukHOME.setText("Masuk");
        buttonMasukHOME.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonMasukHOMEActionPerformed(evt);
            }
        });

        buttonKeluar.setText("Keluar");
        buttonKeluar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonKeluarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(jLabel1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(radioDOKTER, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(radioADMIN, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(168, 168, 168)
                        .addComponent(buttonMasukHOME, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(buttonKeluar, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(62, 62, 62)
                .addComponent(jLabel1)
                .addGap(83, 83, 83)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(radioADMIN)
                    .addComponent(radioDOKTER))
                .addGap(28, 28, 28)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buttonKeluar, javax.swing.GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE)
                    .addComponent(buttonMasukHOME, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(45, Short.MAX_VALUE))
        );

        jPanel1.setBounds(0, 0, 610, 310);
        jDesktopPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        frameLOGIN.setTitle("Form Login Admin");

        jLabel4.setText("Username");

        jLabel5.setText("Password");

        butonLogin.setText("Login");
        butonLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butonLoginActionPerformed(evt);
            }
        });

        butonKembaliLogin.setText("Kembali");
        butonKembaliLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butonKembaliLoginActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout frameLOGINLayout = new javax.swing.GroupLayout(frameLOGIN.getContentPane());
        frameLOGIN.getContentPane().setLayout(frameLOGINLayout);
        frameLOGINLayout.setHorizontalGroup(
            frameLOGINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameLOGINLayout.createSequentialGroup()
                .addGroup(frameLOGINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(frameLOGINLayout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addGroup(frameLOGINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addGap(53, 53, 53)
                        .addGroup(frameLOGINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(username1, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
                            .addComponent(password1)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, frameLOGINLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(butonLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(butonKembaliLogin)))
                .addContainerGap(77, Short.MAX_VALUE))
        );
        frameLOGINLayout.setVerticalGroup(
            frameLOGINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameLOGINLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(frameLOGINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(username1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(frameLOGINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(password1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(frameLOGINLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(butonLogin)
                    .addComponent(butonKembaliLogin))
                .addContainerGap(31, Short.MAX_VALUE))
        );

        frameLOGIN.setBounds(0, 0, -1, 180);
        jDesktopPane1.add(frameLOGIN, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonKeluarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonKeluarActionPerformed
        dispose();        // TODO add your handling code here:
    }//GEN-LAST:event_buttonKeluarActionPerformed

    private void radioDOKTERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioDOKTERActionPerformed
        radioADMIN.setSelected(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_radioDOKTERActionPerformed

    private void radioADMINActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioADMINActionPerformed
        radioDOKTER.setSelected(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_radioADMINActionPerformed

    private void butonLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonLoginActionPerformed
        // TODO add your handling code here:
        String user = username1.getText();
        String pass = password1.getText();
        if (user.equals("admin") && pass.equals("admin")) {
            JOptionPane.showMessageDialog(this, "Selamat Datang \nAnda berhasil Login!");
            //frameDAFTAROBATADMIN.setVisible(true);
            frameLOGIN.setVisible(false);
            frameHOMEPAGE fhp = new frameHOMEPAGE();
            fhp.setVisible(false);
            FrameDaftarObatAdmin fdoa = new FrameDaftarObatAdmin();
            fdoa.setVisible(true);
            radioADMIN.setEnabled(false);
            radioDOKTER.setEnabled(false);
            buttonMasukHOME.setEnabled(false);
            buttonKeluar.setEnabled(false);
        } else {
            JOptionPane.showMessageDialog(this, "Usename & password salah \nUlangi lagi!");
            frameLOGIN.setVisible(true);
            radioDOKTER.setSelected(false);
            radioADMIN.setSelected(false);
            username1.setText("");
            password1.setText("");

            frameHOMEPAGE fhp = new frameHOMEPAGE();
            fhp.setVisible(false);
        }

    }//GEN-LAST:event_butonLoginActionPerformed

    private void butonKembaliLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butonKembaliLoginActionPerformed
        // TODO add your handling code here:
        frameLOGIN.setVisible(false);
        radioDOKTER.setSelected(false);
        radioADMIN.setSelected(false);
        username1.setText("");
        password1.setText("");

        buttonMasukHOME.setEnabled(true);
        radioADMIN.setEnabled(true);
        radioDOKTER.setEnabled(true);
        buttonKeluar.setEnabled(true);
}//GEN-LAST:event_butonKembaliLoginActionPerformed

    private void buttonMasukHOMEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMasukHOMEActionPerformed
        if (radioADMIN.isSelected()) {
            
            frameLOGIN fl = new frameLOGIN();
            fl.setVisible(true);
            dispose();
        } else if (radioDOKTER.isSelected()){
            frameDOKTER fd = new frameDOKTER();
            fd.setVisible(true);
            dispose();
//            radioADMIN.setEnabled(false);
//            radioDOKTER.setEnabled(false);
//            buttonKeluar.setEnabled(false);
//            buttonMasukHOME.setEnabled(false);
//            frameHOMEPAGE fhp = new frameHOMEPAGE();
//            fhp.setVisible(false);
//            fhp.setEnabled(false);

        }
        // TODO add your handling code here:
    }//GEN-LAST:event_buttonMasukHOMEActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());


                    break;



                }

            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frameHOMEPAGE.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frameHOMEPAGE.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frameHOMEPAGE.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frameHOMEPAGE.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frameHOMEPAGE().setVisible(true);


            }
        });


    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton butonKembaliLogin;
    private javax.swing.JButton butonLogin;
    private javax.swing.JButton buttonKeluar;
    private javax.swing.JButton buttonMasukHOME;
    private javax.swing.JInternalFrame frameLOGIN;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPasswordField password1;
    private javax.swing.JRadioButton radioADMIN;
    private javax.swing.JRadioButton radioDOKTER;
    private javax.swing.JTextField username1;
    // End of variables declaration//GEN-END:variables
}
